package com.example.controller;

import com.example.entity.Page.PageRequest;
import com.example.entity.SlideshowImage;
import com.example.result.CommonResult;
import com.example.service.SlideshowImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author: tobed
 * @date: 2022/11/16
 * @time: 15:44
 */
@RestController
@RequestMapping("slideshowImage")
public class SlideshowImageController {

    @Autowired
    SlideshowImageService service;

    /*轮播图全查*/
    @GetMapping("list")
    public CommonResult list(PageRequest pageRequest, SlideshowImage slideshowImage){
        CommonResult commonResult = service.list(pageRequest,slideshowImage);
        return commonResult;
    }

    /*轮播图上传*/
    @PostMapping("create")
    public CommonResult list(MultipartFile file, SlideshowImage slideshowImage) throws IOException {
        CommonResult commonResult = service.create(file,slideshowImage);
        return commonResult;
    }

    /*轮播图删除*/
    @PostMapping("remove/{id}")
    public CommonResult remove(@PathVariable Integer id){
        CommonResult commonResult = service.remove(id);
        return commonResult;
    }

    /*轮播图信息修改*/
    @PostMapping("update")
    public CommonResult update(MultipartFile file,SlideshowImage slideshowImage) throws IOException {
        CommonResult commonResult = service.update(file,slideshowImage);
        return commonResult;
    }

}
